package com.prothink.controller;

import com.prothink.entity.TreeNode;
import com.prothink.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * @description ：用户相关，信息，菜单
 * @author     ：sumnight
 * @projectName ：UserController
 * @date       ：2022/11/11 10:14
 */
@Slf4j
@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * @author: sumnight
     * @description: TODO
     * @date: 2022/11/13 9:00
     * @params: lv 伪权限登录
     * @return: TreeNode 权限获取菜单信息集合
     */
    @ResponseBody
    @RequestMapping("/getMenus")
    public List<TreeNode> getMenus(HttpServletResponse response,Integer lv){
        log.info("获取了菜单对象 等级为{}",lv);
        response.addHeader("Access-Control-Allow-Origin","*");
        response.addHeader("Access-Control-Allow-Method","POST,GET");
        return userService.getMenuTree(lv);
    }

    @ResponseBody
    @RequestMapping("/login")
    public String login(HttpServletResponse response){
        String abc ="欢迎光临";
        return abc;
    }

}
